home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr46
/
vfwdk.zip
/
VFWSDK.ZIP
/
SAMPLES
/
WRITEAVI
/
MULDIV32.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-01-31
|
2KB
|
72 lines
page ,132
;---------------------------Module-Header-------------------------------;
; Module Name: MULDIV32
;
; Copyright (c) 1987-1993 Microsoft Corporation
;-----------------------------------------------------------------------;
?WIN = 0
?PLM = 1
?NODATA = 0
.xlist
include cmacros.inc
include windows.inc
.list
ifndef SEGNAME
SEGNAME equ <_TEXT>
endif
createSeg %SEGNAME, CodeSeg, word, public, CODE
sBegin CodeSeg
.386
assumes cs,CodeSeg
assumes ds,nothing
assumes es,nothing
;---------------------------Public-Routine------------------------------;
; muldiv32
;
; multiples two 32 bit values and then divides the result by a third
; 32 bit value with full 64 bit presision
;
; lResult = (lNumber * lNumerator) / lDenominator
;
; Entry:
; lNumber = number to multiply by nNumerator
; lNumerator = number to multiply by nNumber
; lDenominator = number to divide the multiplication result by.
;
; Returns:
; DX:AX = result of multiplication and division.
; Error Returns:
; none
; Registers Preserved:
; DS,ES,ESI,EDI
;-----------------------------------------------------------------------;
assumes ds,nothing
assumes es,nothing
cProc muldiv32,<PUBLIC,FAR,PASCAL>,<>
; ParmD ulNumber
; ParmD ulNumerator
; ParmD ulDenominator
cBegin
pop edx ; return addr
pop ebx ; ulDenominator
pop ecx ; ulNumerator
pop eax ; ulNumber
push edx ; put back return addr
imul ecx ; edx:eax = (lNumber * lNumerator)
idiv ebx ; eax = (lNumber * lNumerator) / lDenominator
shld edx,eax,16 ; move HIWORD(eax) to dx
cEnd
sEnd CodeSeg
end